#购物系统业务需求V1.0：
money = 500
ShopCar = []
goods = {'巧克力': 20, '冰淇凌': 30, '饼干': 10, '奶茶': 40, '面包': 60}
price = []
for e in goods.values():
    price.append(e)
#print(price)
buy = input('请输入你要购买的商品:')
if buy in goods.keys():
    if money >= goods[buy]:
        ShopCar.append(buy)
        money -= goods[buy]
        print(f'恭喜，购买成功！您的卡余额还剩{money}')
    else:
        print('穷鬼，钱不够！请到其他超市购买！')
else:
    print('没有这个商品，别瞎弄！')
while True:
    result = input('购买已结束请输入Q或q退出')
    if result == 'q' or result == 'Q':
        print(ShopCar)
        break

#购物系统业务需求V2.0：
import random
num = 0
money = 500
ShopCar = []
goods = {'巧克力': 20, '冰淇凌': 30, '饼干': 10, '奶茶': 40, '面包': 60}
price = []
good = []
discount = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
result = random.choice(discount)
print(result)
buy = input('请输入你要购买的商品:')
for e in goods.values():
    price.append(e)
for i in goods.keys():
    good.append(i)
def dell():
    print('是否想要这个商品如果想要请输入yes否则请输入no:')
    answer = input('请输入你的选择:')
    if answer == 'no':
       good.append(buy)
    else:
        ShopCar.append(buy)
        global result
        result /= 10
        result = goods[buy] * result
        global money
        money -= result
        good.remove(buy)
        global num
        num += 1
        print(f'恭喜，购买成功！您的卡余额还剩{int(money)}')
        print(f'购买商品的总价值是{goods[buy]}')
        print(f'购买商品的数量是{num}')
        print('请继续购物')
#print(price)
if buy in goods.keys():
    if money >= goods[buy]:
        dell()
    else:
        print('穷鬼，钱不够！请到其他超市购买！')
else:
    print('没有这个商品，别瞎弄！')
while True:
    result = input('购买已结束请输入Q或q退出')
    if result == 'q' or result == 'Q':
        print(ShopCar)
        break